home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 145 / 145.d81 / t.disc e < prev    next >
Text File  |  2022-08-26  |  24KB  |  1,033 lines

  1.  
  2.  
  3.  
  4.  
  5.  A complete dissection of Gfx-Zone
  6.  
  7.            by XmikeX
  8.  
  9.  
  10.     [Note from Jeff:] some of this
  11. listing may not print properly in the
  12. 6-column mode.
  13.  
  14.     The following is a disassembly of
  15. the ML code itself.  Although I won't
  16. go through it 100% step by step,
  17. important points shall be perused for
  18. the purposes of clarification, and to
  19. be honest, for a little self-
  20. introspection on my part.
  21.  
  22.   The program starts out quite simply
  23. with the start address and a
  24. labelling of important memory
  25. locations (generally used as pointers
  26. throughout the program).
  27.  
  28.  ;--------------------------------
  29.    *= $c000; start of program
  30.  ;--------------------------------
  31.  point = $fb ; LSB = point  ($fb)
  32.    ; MSB = point+1 ($fc)
  33.  temp  = $cfff ; MSB byte storage
  34.  temp2 = $cffe ; used by FLD routine
  35.  temp3 = $cffd ; $cffa/cffb for
  36.  ; TBB/AMJ player uses these.
  37.  looper = $ccfc ; see pause routine
  38.  hit  = $ccf9 ; see pause routine
  39.  ;----------------------------------
  40.  
  41.  init lda #$36 ; #$36 is our
  42.  ;kill-basic value, so
  43.  sta $01 ; store the kill-basic value
  44. into $01 and move the
  45.   ; basic rom out of the way,
  46. exposing the ram underneath.
  47.  
  48. [AssEd. Note : For general
  49. edification, location $01 works as
  50. follows in C64]
  51. [ - bit 0: ROM/RAM at $a000 1=Basic
  52. 0=RAM]
  53. [ - bit 1: ROM/RAM at $e000 1=Kernal
  54. 0=RAM]
  55. [ - bit 2: ROM or I/O block 1=I/O
  56. 0=ROM]
  57. [ - bits 3,4,5 are cassette
  58. related........]
  59. [ - bits 6 & 7 are not connected in
  60. the C64]
  61. [ - bit 6 checks the status of the
  62. caps lock (ascii/cc) key on C128.]
  63.  
  64.  lda #$00 ; ok...set up accumulator
  65. as #$00
  66.  sta $d020; change screen and
  67.  sta $d021; border to black (i.e.,
  68. #$00)
  69.  sta point; store LSB of pointer
  70. (which is now #$00)
  71.  lda #$00 ; initialize the looper
  72.  sta looper
  73.  
  74.     Ok... So what is going on here?
  75. Basically, we are telling Basic to
  76. take a hike so that we can use the
  77. memory it once inhabited. We are also
  78. setting up the LEAST SIGNIFICANT BYTE
  79. pointer for the indirect Y function.
  80. This is a powerful tool in 6502
  81. assembly and we will get to it later
  82. :). The "looper" is just a memory
  83. location that the program will use in
  84. its "pause" subroutine. Right now, it
  85. is set at zero (#$00).
  86.  
  87.  
  88.    UGLY lda #$fa ; try and tell
  89. tbb/amj music player
  90.  
  91.    sta $105b; what scanline to play
  92. at
  93.  
  94.    amjtune jsr $1000; jsr call to
  95. sys4096/amj's TBB player at $1000
  96.  
  97.  
  98.     This part is really UGLY.
  99. Basically, I tried to extract the
  100. music player and tried to incorporate
  101. it here, but I failed for some
  102. unknown reason. I decided that since
  103. it was proving to be uncooperative
  104. that I should just call it from here
  105. and let it go off on its own. This
  106. presented two problems for me later.
  107. The first was that the music was
  108. playing at raster lines that were
  109. outside the border area. In layman's
  110. terms this means that it would play
  111. in the middle of the screen and a
  112. slight flicker could be seen as the
  113. main code flipped through the pics. I
  114. rectified the situation by finding
  115. out where it was polling its raster
  116. info ($105b) and sticking an #$fa in
  117. there. #$fa is raster line 250, which
  118. should correspond to the lower border
  119. on the screen. Yes, I could have
  120. modified the player code itself, but
  121. I was getting a bit paranoid at this
  122. juncture and decided not to modify
  123. it. The second problem is that by
  124. giving up control to the player
  125. subroutine, I lost control of timing,
  126. an annoyance that which we shall
  127. discuss later. Anyways, as you can
  128. see I call the player in the
  129. 'amjtune' subroutine and let it do
  130. its thing, but even though it is not
  131. in the main code, I've included the
  132. player here for the benefit of the
  133. reader. As this code is from someone
  134. else, I cannot assure a 100% correct
  135. disassembly, but read on..
  136.  
  137.  
  138.     TBB player from SYS4096 tune by
  139. AMJ starts at $1000 and proceeds as
  140. follows: (By the way, TBB is AMJ's
  141. brother...trivia mode over).
  142.  
  143. <start of player code>
  144.  
  145.  > sei ; disables interrupts
  146.  > lda #$01
  147.  > sta $d01a ; set up for scan line
  148.  > lda #$7f
  149.  > sta $dc0d ; enable timer interpts
  150.  > lda #$35  ; lets play with roms
  151.  > sta $01
  152.  > lda #$00
  153.  > ldx #$00
  154.  > ldy #$00
  155.  > jsr $1100 ; jsr to musix init ?
  156.  > lda #$37  ; let's play with roms
  157.  > sta $01
  158.  > lda #<irq ; LSB of irq
  159.  > sta $0314 ; stash it
  160.  > lda #>irq
  161.  > sta $0315 ; MSB of irq
  162.  > lda #$3a
  163.  > sta $d012
  164.  > lda #$1b  ; normalize the screen i
  165. think
  166.  > sta $d011
  167.  > cli ; re-enables interrupts
  168.  > rts ; it used to jmp back to
  169. itself, infinite loop
  170.  > ; as its irq routine played in the
  171. backgroud
  172.  
  173.  >irq lda #$01  ; the irq routine
  174.  > sta $d019
  175.  > lda #$35  ; let's play with roms
  176. again
  177.  > sta $01
  178.  > dec $d020
  179.  > jsr $1103 ; $1103 (!) I think this
  180. jsr's to musix data
  181.  > inc $d020
  182.  > lda #$37  ; let's play with roms
  183. yet again
  184.  > sta $01
  185.  > inc selfmod+1 ; self-modifying
  186. code!!!
  187.  >selfmod lda #$xx  ; #$xx = this is
  188. the byte changed by 'inc selfmod+1'
  189.  > and #$01
  190.  > tax
  191.  > lda #$105b,x ; goes to the scan
  192. line table ?
  193.  > sta $d012 ; sets up the scan line
  194. for irq to occur
  195.  > jmp $ea31 ; go to normal c= irq
  196. return
  197.  
  198. <end of player code>
  199.  
  200.     From $105c to $10a0 or so beyond
  201. this there is some program data of
  202. unknown function.  At around $1100
  203. there is an embedded message by the
  204. authors and then the music data
  205. follows, ending somewhere around
  206. $26b0 if I recall correctly. Please
  207. note that this tune is double-speed
  208. (i.e., plays twice per frame).
  209.  
  210.    <back to main program code>
  211.  
  212.    The initialization steps have
  213. executed and the music player has
  214. been told to start playing.  What is
  215. left now is to present the C/G
  216. pictures to the viewer in a
  217. meaningful way.
  218.  
  219.    The main1 routine that follows
  220. conducts the sequence of the C/G
  221. displays. Its responsibility is to
  222. load and store the MOST SIGNIFICANT
  223. BYTE of the address (location) of
  224. each starting pic for a given pattern
  225. of displays and then branch out to
  226. the pattern subroutines, which
  227. display c/g pics sequentially given a
  228. predetermined sequence. Again, the
  229. MSB as with the LSB we encountered
  230. earlier deals with the indirect Y
  231. function that we shall explore
  232. later.
  233.  
  234.   main1  lda #$30 ; starting pic MSB
  235.  sta temp ; store MSB in temp
  236.  jsr pattern
  237.  
  238.  lda #$30 ; starting pic MSB
  239.  sta temp ; store MSB in temp
  240.   jsr pattern0
  241.  
  242.   lda #$c0 ; this MSB is being stored
  243. but pattern1 does not use it
  244.   sta temp
  245.   jsr pattern2
  246.   jsr pattern1; fld bounce of the
  247. first intro pic only
  248.    ; located at $3000-$37e7
  249.    ; fld effect is quite annoying, so
  250. its done only once
  251.   lda #$38
  252.   sta temp
  253.   jsr p0  ; p0 routine is a part
  254. (subset) of pattern0 routine
  255.  
  256.   lda #$c0  ; the rest of these are
  257. more of the same... calls to
  258.   sta temp  ; pattern subroutines
  259.   jsr pattern2
  260.  
  261.   lda #$38
  262.   sta temp
  263.   jsr pattern0
  264.  
  265.   lda #$c0
  266.   sta temp
  267.   jsr pattern2
  268.  
  269.   lda #$30
  270.   sta temp
  271.   jsr pattern0
  272.  
  273.   lda #$c0
  274.   sta temp
  275.   jsr pattern2
  276.  
  277.   lda #$30
  278.   sta temp
  279.   jsr pattern0
  280.  
  281.   lda #$c0
  282.   sta temp
  283.   jsr pattern2
  284.  
  285.   lda #$38
  286.   sta temp
  287.   jsr p0
  288.  
  289.   lda #$c0
  290.   sta temp
  291.   jsr pattern2
  292.  
  293.   lda #$38
  294.   sta temp
  295.   jsr p0
  296.  
  297.   lda #$c0
  298.   sta temp
  299.   jsr pattern2
  300.  
  301.   jsr pattern3; last pattern before
  302. music loops back on itself
  303.  
  304.   jmp main1
  305.  
  306.   By now, music has looped...time to
  307. slow down again with the original
  308. pattern at the start of main1 routine
  309. (i.e., pattern routine that follows
  310. is called at the start of main1)
  311.  
  312.  
  313.     "pattern" is the first of the
  314. pattern subroutines.  Its
  315. responsibility is to take care of the
  316. first and second intro pics at the
  317. start of the program. It pulls the
  318. MSB from the temp memory location
  319. (the first intro pic), jsrs to the
  320. viewpic routine, and loads a "hit"
  321. value which the "pause" routine
  322. will then compare with an "looper"
  323. value.  This determines how long the
  324. first intro pic will be shown.  After
  325. which, "pattern" will change the MSB
  326. value (without affecting the MSB in
  327. temp) to point to the second intro
  328. pic, and then it repeats this process
  329. until the music tempo increases, upon
  330. which time "pattern" gives up control
  331. to another "patternX" subroutine.
  332.  
  333.     I mentioned earlier that I lost
  334. control of timing when I gave up some
  335. control to the music player code.
  336. That is to say, because I could not
  337. (at the time) incorporate the player
  338. code in here, I had no way of
  339. properly synching the pictures to the
  340. beat of the music as it played.  I
  341. corrected this deficiency in true
  342. 'newbie' fashion.  I used delay loops
  343. to form the core basis of what I
  344. could ap